<?php
/** 初始化项目 */
require '../../app/app.php';
/** 初始化数据库 */
use app\util\Mysql;
$database = Mysql::init();

$client_ip = getClientIP();
$timestamp = time();
$username = $_SESSION["username"];
if (isset($_SESSION['username']) && $_SESSION['username'] != "") {

    if ($_GET["dellog"] == "syslog") {
        $timeold = time() - 31536000;
        $database->delete("secure_info", ["times[<]" => $timeold]);
        $content = $username . "删除了一年以前的安全记录。";
        $database->insert("secure_info", ["user" => $username, "ip" => $client_ip, "times" => $timestamp, "content" => $content]);
        echo "删除成功";
    }elseif ($_GET["dellog"] == "loginlog") {
        $timeold = time() - 31536000;
        $database->delete("user_login_info", ["logintime[<]" => $timeold]);
        $content = $username . "删除了一年以前的登录记录。";
        $database->insert("secure_info", ["user" => $username, "ip" => $client_ip, "times" => $timestamp, "content" => $content]);
        echo "删除成功";
    }else{

    }
}else{
    echo "<script>alert('请先登录！');window.location.href='/?c=login';</script>";
}
